package com.dts.listener;

import jakarta.servlet.annotation.WebListener;
import jakarta.servlet.http.HttpSessionAttributeListener;
import jakarta.servlet.http.HttpSessionBindingEvent;

import java.text.MessageFormat;

@WebListener
public class MySessionAttributeLitener  implements HttpSessionAttributeListener {
    @Override
    public void attributeAdded(HttpSessionBindingEvent event) {
        System.out.println(MessageFormat.format("HttpSession add Attribute  name : {0}，value : {1}", event.getName(), event.getValue()));
    }
    @Override
    public void attributeReplaced(HttpSessionBindingEvent event) {
        System.out.println(MessageFormat.format("HttpSession replace Attribute name : {0}，value : {1}", event.getName(),event.getValue()));
    }
    @Override
    public void attributeRemoved(HttpSessionBindingEvent event) {
        System.out.println(MessageFormat.format("HttpSession remove Attribute name : {0}，value : {1}", event.getName(), event.getValue()));
    }
}
